/*
 * @FilePath: screen.ts
 * @Author: jack
 * @Date: 2024-06-17 11:55:44
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2024-06-17 11:57:00
 * Copyright: 2024 xxxTech CO.,LTD. All Rights Reserved.
 * @Descripttion: 
 */
// 数据大屏存储的数据
import { defineStore } from 'pinia'
export const PiniaStore = defineStore('pcvideo', {
    state: () => {
        return {
            isCollapse: false,
            tableHeight: 0,
            searchHeight: 0,
            innerHeight: window.innerHeight / 2,
            showPagition: true,
            searchShow: false,
            mainHeight: 0,
            pageQuery: {
                page: 1,
                page_size: 20
            },
            visitedRoutes: [] as any,
            schoolList: [] as any
        }
    },
    persist: {
        key: 'pcvideo',
        storage: window.sessionStorage
    },
    actions: {
        setCollapse(params: any) {
            this.isCollapse = params
        },
        setPageQueryPage(params: any, count?: boolean) {
            if (count) {
                this.pageQuery.page += params
            } else {
                this.pageQuery.page = params
            }
        },
        setPageQueryPageSize(params: any) {
            this.pageQuery.page_size = params
        },
        // 初始化page组件
        setRefreshPage() {
            this.pageQuery.page = 1
            this.pageQuery.page_size = 20
        },
        // 没有搜索框
        setTableHeight2() {
            this.tableHeight = window.innerHeight - this.searchHeight - 285
        },
        // 获取表格的高度
        setTableHeight() {
            this.tableHeight = window.innerHeight - this.searchHeight - 279
        },
        // 记录search高度
        setSearchHeight(params: any) {
            this.searchHeight = params
            this.tableHeight = window.innerHeight - params - 285
        },
        // 判断是否需要呈现pagition组件，为了解决keep-alive问题
        setShowPagition(params: boolean) {
            this.showPagition = params
        },
        setMainHeight(params: number) {
            this.mainHeight = params
        },
        //  记录search 的查询框条数
        setSearchCount(bol?: boolean) {
            if (bol !== null && bol !== undefined) {
                this.searchShow = bol
            } else {
                this.searchShow = !this.searchShow
            }
        },
        // 存储路由
        setVisitedRoutes(item?: any) {
            this.visitedRoutes.push(item)
        }
    }
})